<template>
  <div class="simiSinger">
    <h2>相似歌手</h2>
    <div class="content" v-if="list.length === 0">
      <div class="content_item" v-for="item in 20" :key="item">
        <el-skeleton animated :throttle="500" style="width: 100%">
          <template slot="template">
            <el-skeleton-item
              variant="image"
              style="height: 220px; width: 224px"
            />
          </template>
        </el-skeleton>
      </div>
    </div>
    <div class="content" v-else>
      <div
        class="content_item"
        v-for="item in list"
        :key="item.id"
        @click="toSingerDetailsPage(item.id)"
      >
        <div class="content_item_pic">
          <GlobalImageDeep
            :url="item.picUrl"
            :imgWidth="155"
            :imgHeight="155"
          />
        </div>
        <div class="name">{{ item.name }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import { getSimiSinger } from "../../../../../api/singerDetailsApi";
export default {
  name: "simiSinger",
  components: {},
  props: {
    id: {
      required: true,
      type: Number,
    },
  },
  data() {
    return {
      list: [],
    };
  },
  created() {
    this.getSimiSingerMethod();
  },
  methods: {
    async getSimiSingerMethod() {
      try {
        let result = await getSimiSinger(this.id);
        if (result.code === 200) {
          this.list = result.artists;
        }
      } catch (error) {}
    },
    toSingerDetailsPage(id) {
      this.$router.push(`/singerDetails/${id}`);
    },
  },
  computed: {},
  watch: {
    id: {
      // deep: true,
      handler(newValue) {
        // console.log("获取到的最新的id", newValue);
        this.getSimiSingerMethod();
      },
    },
  },
};
</script>

<style lang="less" scoped>
.simiSinger {
  color: #000000;
  font-size: 14px;
  padding: 20px 0;
  h2 {
    font-weight: normal;
    font-size: 24px;
    margin-bottom: 10px;
  }
  .content {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    .content_item {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 220px;
      height: 224px;
      border-radius: 8px;
      background-color: #f8f8f8;
      margin-bottom: 15px;
      /deep/ .el-image img {
        border-radius: 50%;
      }
      &:hover {
        cursor: pointer;
      }
      .content_item_pic {
        position: relative;
        width: 155px;
        height: 155px;
        overflow: hidden;
      }
      .name {
        padding-top: 10px;
        font-size: 14px;

        &:hover {
          color: @globalColor;
          cursor: pointer;
          animation: bounce 1s;
        }
      }
    }
  }
}
</style>
